package test05;

public class Test41 {
    public static void main(String[] args) {
        Employee employees[]={new SalariedEmployee(),new HourlyEmployee(),new SalesEmployee(),new BasePlusSalesEmployee()};
        employees[0].setMonth(2);
        employees[1].setMonth(5);
        employees[2].setMonth(7);
        employees[3].setMonth(9);
        double salary1=employees[0].getSalary(2);
        double salary2=employees[1].getSalary(3);
        double salary3=employees[2].getSalary(6);
        double salary4=employees[3].getSalary(9);
        System.out.println(salary1);
        System.out.println(salary2);
        System.out.println(salary3);
        System.out.println(salary4);
    }
}
class Employee{
    private String name;
    private int month;

    public double getSalary(int month){
        return 0;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }
}
class SalariedEmployee extends Employee{
    private double salary=3000;

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public double getSalary(int month) {
        if(month==this.getMonth()){
            return salary+100;
        }else{
            return salary;
        }
    }
}
class HourlyEmployee extends Employee{
    private double hourlySalary=9;
    private int hours=12;

    public double getHourlySalary() {
        return hourlySalary;
    }

    public void setHourlySalary(double hourlySalary) {
        this.hourlySalary = hourlySalary;
    }

    public int getHours() {
        return hours;
    }

    public void setHours(int hours) {
        this.hours = hours;
    }

    @Override
    public double getSalary(int month) {
        if(month==this.getMonth()){
            return hourlySalary*hours*30+100;
        }else{
            return hours*hourlySalary*30;
        }
    }
}
class SalesEmployee extends Employee{
    private double sales=10000;
    private double rate=0.3;

    public double getSales() {
        return sales;
    }

    public void setSales(double sales) {
        this.sales = sales;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    @Override
    public double getSalary(int month) {
        if(month==this.getMonth()){
            return sales*rate+100;
        }else{
            return sales*rate;
        }
    }
}
class BasePlusSalesEmployee extends SalariedEmployee{
    private double baseSalary=1500;

    public double getBaseSalary() {
        return baseSalary;
    }

    public void setBaseSalary(double baseSalary) {
        this.baseSalary = baseSalary;
    }

    @Override
    public double getSalary(int month) {
        return super.getSalary(month)+baseSalary;
    }
}
